package com.junlong0716.enjoylearning.dialog

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import com.junlong0716.enjoylearning.R
import kotlinx.android.synthetic.main.dialog_loading_view.*

/**
 * @author: 巴黎没有摩天轮Li
 * @description:
 * @date: Created in 下午9:54 2018/5/21
 * @modified by:
 */
class LoadingDialog(context: Context):Dialog(context, R.style.main_dialog){
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.dialog_loading_view)
    }

    /**
     * 设置dialog位于屏幕底部
     */
    private fun setViewLocation() {
        window.attributes.gravity = Gravity.CENTER
        val lp = window!!.attributes
        lp.width = ViewGroup.LayoutParams.WRAP_CONTENT
        lp.height = ViewGroup.LayoutParams.WRAP_CONTENT
        // 设置显示位置
        onWindowAttributesChanged(lp)
    }

    fun setProgress(progress:String){
        tv_progress.visibility = View.VISIBLE
        tv_progress.text = progress
    }

    interface ProgressCallback{
        fun setProgress()
    }
}
